﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

namespace d39.Controls
{
    public partial class ColorPicker : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(ColorPicker), "init" + ClientID, "initColorPicker('" + ColorTextBox.ClientID + "', '" + PickerHolder.ClientID + "');", true);
        }
        public Color Color
        {
            get { return ColorTranslator.FromHtml(ColorTextBox.Text); }
            set
            {
                var color = Color.FromArgb(value.R, value.G, value.B); // Make sure we aren't using a named color; also strip out any alpha
                ColorTextBox.Text = ColorTranslator.ToHtml(value);
            }
        }
    }
}